package com.chery.media.library.contacts

import com.blankj.utilcode.util.FileUtils
import com.blankj.utilcode.util.LogUtils
import com.blankj.utilcode.util.PathUtils
import java.io.File

/**
 *  @author: pandeng
 *  @className: PathContacts
 *  @description: 路径
 *  @date: 2022/12/24
 */
object PathContacts {

    //缓存路径
    val CACHE_PATH: String by lazy { PathUtils.getExternalAppCachePath() }

    //存储路径
    private val FILES_PATH: String by lazy { PathUtils.getExternalAppFilesPath() }

    //下载图片
    val IMG_DOWNLOAD by lazy { "${FILES_PATH + File.separator}download"}

    //压缩图片
    val IMG_COMPRESS by lazy { "${FILES_PATH + File.separator}compress"}

    //裁剪图片
    val CUT_COMPRESS by lazy { "${FILES_PATH + File.separator}Pictures"}

    //APK下载路径
    val APK_DOWNLOAD by lazy { "${FILES_PATH + File.separator}apk"}

    //创建文件
    fun createFile(path: String): File{
        val isExists = FileUtils.createOrExistsFile(File(path))
        if (isExists) LogUtils.e("创建文件成功") else LogUtils.e("创建文件失败")
        return if (isExists) File(path) else File(path)
    }

    //创建文件夹
    fun createFileDir(path: String): File{
        val isExists = FileUtils.createOrExistsDir(path)
        if (isExists) LogUtils.e("创建文件夹成功") else LogUtils.e("创建文件夹失败")
        return if (isExists) File(path) else File(path)
    }

    //删除文件
    fun deleteFile(){
        FileUtils.delete(IMG_COMPRESS)
        FileUtils.delete(CUT_COMPRESS)
        FileUtils.delete(APK_DOWNLOAD)
    }

}